﻿    namespace LocalizationLibrary.Messaging
{
    //.NET References
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    /// <summary>
    /// Defines the messaging manager.
    /// </summary>
    internal class MessagingManager
    {
        //Events

        /// <summary>
        /// Occurs when a message is published.
        /// </summary>
        public static event MessageEventHandler OnMessage;

        //Methods

        /// <summary>
        /// Publishes the input <paramref name="message"/>.
        /// </summary>
        /// <param name="message"></param>
        public static void Publish(IMessage message) 
        {
            if (message != null)
            {
                MessageEventHandler handler = MessagingManager.OnMessage as MessageEventHandler;
                if (handler != null)
                {
                    handler(typeof(MessagingManager), new MessageEventArgs(message));
                }
                String strMessage = String.Format("[MESSAGE] {0}", message.GetMessage());
                ConsoleExtended.WriteLine(strMessage);
            }
        }
    }
}